<template>
	<view >
		<view class="top u-flex">
			<view class="u-flex-6 u-m-l-20 u-m-r-20">
				<u-image width="250rpx" height="250rpx" :src="poster" shape="square" border-radius="20"></u-image>
			</view>
			
			<view class="">
				{{book.name}}
			</view>
		</view>
		<view class="u-m-l-20 u-m-r-20">
			<view class="u-m-t-20">
				<view class="u-text-center" style="font-size: 35rpx; color: #f29100; font-weight: bolder;">
					资源列表<text style="font-size: 20rpx;color: #909399;">({{fileList.length}})</text>
				</view>
				<view class="u-m-t-20">
					<view class="fileItem u-m-t-30" v-for="(item,index) in fileList">
						<view class="item u-flex " >
							<view class="u-flex-1 u-text-center" style="color:#909399 ;">{{index + 1}}</view>
							<view class="u-flex-6 u-line-2 u-m-r-20">{{item.file.fileName}}</view>
							<view class="u-flex-1 u-text-center  u-m-t-10">
								<u-link :href="baseUrl+item.id" :under-line="false">
									<u-icon name="download" color="#ff9900" size="40" :label="item.download" label-color="#f29100"></u-icon>
								</u-link>
									
								
								
								
							</view>
						</view>
						
					</view>
				</view>
			</view>
			
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bid:0,
				book:{},
				fileList:[],
				audioPlay:false,
				src:'',
				name:'',
				poster:'',
				baseUrl:'http://114.132.229.158:9009/download/bookFile/'
			}
		},
		onLoad(val) {
			
			this.bid = val.id
			this.getFile()
		},
		methods: {
			async download(val){
		// 		const downloadTask = uni.downloadFile({
		// 			url: 'http://dongdong.com:8080/download/bookFile/' + val, 
		// 				success: (res) => {
		// 					if (res.statusCode === 200) {
		// 						console.log('下载成功');
		// 					}
		// 					this.dd = res.tempFilePath;
		// 					console.log(this.dd);
		// 			}
		// 		});
		
		// 		downloadTask.onProgressUpdate((res) => {
		// 			console.log('下载进度' + res.progress);
		// 			console.log('已经下载的数据长度' + res.totalBytesWritten);
		// 			console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
		// 		});
				
			},
			async getFile(){
				const res = await this.$u.api.booksInfo(this.bid)
				this.fileList = res.normal
				this.book = res.book
				
				this.poster = this.vuex_user.store +  this.book.img
				console.log(res)
			}
		}
	}
</script>

<style>
	.fileItem{
		box-shadow: rgba(6, 24, 44, 0.4) 0px 0px 0px 2px, rgba(6, 24, 44, 0.65) 0px 4px 6px -1px, rgba(255, 255, 255, 0.08) 0px 1px 0px inset;
		border-radius: 30rpx;
	}
	.top{
		clear: inherit;
		width: 100%;
		height: 300rpx;
		background-color: #fdf6ec;
	}
	.curPlay{
		width: 200rpx;
		height: 80rpx;
		background-color: #fcbd71;
		font-size: 35rpx;
		color: #FFFFFF;
		line-height: 70rpx;
		
	}
	.audioPlay{
		border: 1rpx solid #fcbd71;
	}
	.item{
		margin-bottom: 10rpx;
		border-radius: 20rpx;
		box-shadow: rgba(17, 17, 26, 0.1) 0px 1px 0px;
		height: 100rpx;
	}
</style>
